// ignore_for_file: prefer_const_constructors

import 'package:get/get.dart';
import 'package:multi_shop/index.dart';
import 'package:multi_shop/models/order_item.dart';
import 'package:multi_shop/pages/merchant_home.dart';
import 'package:multi_shop/pages/my/address.dart';
import 'package:multi_shop/pages/cart.dart' show ShoppingCart;
import 'package:multi_shop/pages/category_products.dart';
import 'package:multi_shop/pages/forget.dart';
import 'package:multi_shop/pages/login.dart';
import 'package:multi_shop/pages/my/profile.dart' show ProfilePage;
import 'package:multi_shop/pages/my/set_pin_page.dart';
import 'package:multi_shop/pages/order.dart';
import 'package:multi_shop/pages/order_detail.dart';
import 'package:multi_shop/pages/order_list.dart';
import 'package:multi_shop/pages/payment_success.dart';
import 'package:multi_shop/pages/register.dart';
import 'package:multi_shop/pages/search_result_page.dart';

import '../pages/detail.dart';
import '../pages/msg.dart';
import '../pages/my.dart';
import '../pages/search_page.dart';

/// 全局路由配置：Detail 页面通过 arguments 接收参数
final List<GetPage> routes = [
  GetPage(name: '/my', page: () => My()),
  GetPage(name: '/msg', page: () => Msg()),
  GetPage(name: '/search_page', page: () => SearchPage()),
  GetPage(name: '/address_page', page: () => AddressPage()),
  GetPage(name: '/order_list', page: () => OrderListPage()),
  GetPage(name: '/search_result', page: () => SearchResultPage()),

  GetPage(
    name: '/detail',
    page: () {
      final args = Get.arguments as int;
      return Detail(id: args);
    },
  ),
  GetPage(name: '/profile', page: () => ProfilePage()),
  GetPage(name: '/cart', page: () => ShoppingCart()),
  GetPage(name: '/login', page: () => LoginPage()),
  GetPage(name: '/register', page: () => RegisterPage()),
  GetPage(name: '/forget', page: () => ForgotPasswordPage()),
  GetPage(name: '/index', page: () => Index()),
  GetPage(
    name: '/category_products',
    page: () {
      final args = Get.arguments as Map<String, dynamic>?;
      return CategoryProductsPage(
        category: args?['category'] ?? '',
        subCategory: args?['subCategory'] ?? '',
      );
    },
  ),
  // 下单页面
  GetPage(
    name: '/order',
    page: () {
      final items = (Get.arguments as List<OrderItem>);
      return OrderPage(items: items);
    },
  ),
  // 地址选择页面
  GetPage(name: '/address', page: () => AddressPage()),
  GetPage(name: "/payment_success", page: () => PaymentSuccessPage()),
  GetPage(name: "/order_list", page: () => OrderListPage()),
  GetPage(
    name: "/order_detail",
    page: () {
      final args = Get.arguments as Map<String, dynamic>?;
      return OrderDetailPage(orderNo: args?["orderNo"]);
    },
  ),

  GetPage(name: "/merchant_home", page: () => MerchantHome()),
  GetPage(name: "/set_pin", page: () => SetPinPage()),
];
